package com.quickcancellation.crm.utils;

import java.security.MessageDigest;

/**
 * MD5 加密工具类
 */
public class MD5Util {
    /**
     * 根据输入
     * @param input
     * @return
     */
    public static String getMD5(String input) {
        try {
            MessageDigest md = MessageDigest.getInstance("MD5");
            byte[] messageDigest = md.digest(input.getBytes());
            StringBuffer hexString = new StringBuffer();
            for (byte b : messageDigest) {
                String hex = Integer.toHexString(0xff & b);
                if (hex.length() == 1) {
                    hexString.append('0');
                }
                hexString.append(hex);
            }
            return hexString.toString();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public static void main(String[] args) {
        String md5 = getMD5("f7c4307cc064d03e5d971757bfef04d9");
        System.out.println(md5);
    }
}